﻿using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using System;
using Volo.Abp.Auditing;
using Volo.Abp.AutoMapper;
using Volo.Abp.Modularity;

namespace Colorful.Furniture.SysManagement;

/// <summary>
///  系统管理模块
/// </summary>
public class SysManagementModule : AbpModule
{
    /// <summary>
    ///  配置
    /// </summary>
    /// <param name="context"></param>
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        //审计日志部分
        var enableAuditing = context.Services.GetConfiguration().GetSection("AuditingLog").Value?.To<bool>() ?? false;

        Configure<AbpAuditingOptions>(options =>
        {
            options.IsEnabled = enableAuditing;
        });

        Configure<AbpAutoMapperOptions>(options =>
        {
            options.AddProfile<SysManagementAutoMapperProfile>();
        });

        if (enableAuditing)
        {
            //替换默认的审计日志实现
            context.Services.Replace(ServiceDescriptor.Transient<IAuditingStore, FurnitureDbAuditingLogStore>());
        }
    }
}